package com.bt.lms.ui.page.stu;

import com.bt.lms.ui.action.registration.stu.*;
import com.bt.lms.ui.page.sys.style.BtnStyle;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Cursor;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.*;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.stage.Stage;


/**
 * 新增学员信息界面
 */
public class PageAddStuInfo extends VBox {
    /**
     * 新增学员信息界面长
     */
    private double preWidth = 1280;

    /**
     * 新增学员信息界面高
     */
    private double preHeight = 800;

    /**
     * 标签默认长度
     */
    private double labDefaultWidth = 200;

    /**
     * id横向盒子
     */
    public static HBox idhBox;

    /**
     * 个人照片横向盒子
     */
    public static HBox photoHBox;

    /**
     * 学历横向盒子
     */
    public static HBox eduBackgroundHBox;


    public PageAddStuInfo() {


        this.setPrefSize(preWidth, preHeight);
        this.setPadding(new Insets(5));
        this.setSpacing(20);

        //顶部横向盒子
        HBox topHBox = new HBox();
        initTopHBox(topHBox);
        //新增报名信息横向盒子
        HBox addApplyInfoHBox = new HBox();
        initAddApplyInfoHBox(addApplyInfoHBox);
        //报名编号横向盒子
        HBox applyNumHBox = new HBox();
        initApplyNumHBox(applyNumHBox);
        //姓名横向盒子
        HBox nameHBox = new HBox();
        initNameHBox(nameHBox);
        //性别横向盒子
        HBox genderHBox = new HBox();
        initGenderHBox(genderHBox);
        //出生日期横向盒子
        HBox birthdayHBox = new HBox();
        initBirthdayHBox(birthdayHBox);
        //证件类型横向盒子
        HBox IDTypeHBox = new HBox();
        initIDTypeHBox(IDTypeHBox);
        //证件号码横向盒子
        HBox IDNumHBox = new HBox();
        initIDNumHBox(IDNumHBox);

        //所属招生计划横向盒子
        HBox ofEnPHBox = new HBox();
        initOfEnPHBox(ofEnPHBox);
        //电子邮箱横向盒子
        HBox emailHBox = new HBox();
        initEmailHBox(emailHBox);
        //移动电话横向盒子
        HBox movePhoneHBox = new HBox();
        initMovePhoneHBox(movePhoneHBox);
        //qq横向盒子
        HBox qqHBox = new HBox();
        initqqHBox(qqHBox);
        //微信横向盒子
        HBox weChatHBox = new HBox();
        initWeChatHBox(weChatHBox);

        //报名材料横向盒子
        HBox applyMaterialHBox = new HBox();
        initApplyMaterialHBox(applyMaterialHBox);
        //上传文件格式横向盒子
        HBox fileUploadHBox = new HBox();
        initFileUploadHBox(fileUploadHBox);
        //身份证横向盒子
        idhBox = new HBox();
        initIDHBox(idhBox);
        //照片横向盒子
        photoHBox = new HBox();
        initPhotoHBox(photoHBox);
        //学历证书盒子
        eduBackgroundHBox = new HBox();
        initEduBackgroundHBox(eduBackgroundHBox);
        //底部横向盒子
        HBox bottomHBox = new HBox();
        initBottomHBox(bottomHBox);


        //滚动条盒子
        VBox scrollPaneVBox = new VBox();
        ScrollPane scrollPane = new ScrollPane();
        scrollPane.setContent(scrollPaneVBox);
        scrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.ALWAYS);
        scrollPane.setPrefSize(preWidth, preHeight);


        scrollPaneVBox.getChildren().addAll(topHBox, addApplyInfoHBox, applyNumHBox, nameHBox, genderHBox, birthdayHBox, IDTypeHBox, IDNumHBox, ofEnPHBox, emailHBox, movePhoneHBox, qqHBox, weChatHBox, applyMaterialHBox, fileUploadHBox,
                idhBox, photoHBox, eduBackgroundHBox, bottomHBox);

        ObservableList<Node> children = this.getChildren();
        children.addAll(scrollPane);


    }


    /**
     * 底部横向盒子
     *
     * @param bottomHBox
     */
    private void initBottomHBox(HBox bottomHBox) {
        bottomHBox.setPadding(new Insets(20));
        bottomHBox.setSpacing(20);
        bottomHBox.setAlignment(Pos.CENTER);
        //保存按钮
        Button saveBtn = new Button("保存");
        BtnStyle.saveBtn(saveBtn);//按钮样式
        saveBtn.setOnMouseEntered(new EventHandler<MouseEvent>() {
            @Override
            public void handle(MouseEvent event) {
                saveBtn.setCursor(Cursor.HAND);
            }
        });

        //保存按钮事件
        PageAddStuSaveBtnAction pageAddStuSaveBtnAction = new PageAddStuSaveBtnAction();
        pageAddStuSaveBtnAction.setPageAddStuInfo(this);
        saveBtn.setOnAction(pageAddStuSaveBtnAction);
        //关闭按钮
        Button closeBtn = new Button("关闭");
        BtnStyle.cancelBtn(closeBtn);
        closeBtn.setOnMouseEntered(new EventHandler<MouseEvent>() {
            @Override
            public void handle(MouseEvent event) {
                closeBtn.setCursor(Cursor.HAND);
            }
        });


        ObservableList<Node> children = bottomHBox.getChildren();
        children.addAll(saveBtn, closeBtn);
        //关闭按钮事件
        PageAddStuCloseBtnAction pageAddStuCloseBtnAction = new PageAddStuCloseBtnAction();
        closeBtn.setOnAction(pageAddStuCloseBtnAction);
    }

    /**
     * 学历证书盒子
     *
     * @param eduBackgroundHBox
     */
    private void initEduBackgroundHBox(HBox eduBackgroundHBox) {
        eduBackgroundHBox.setPadding(new Insets(20));
        eduBackgroundHBox.setSpacing(20);
        //学历证书标签
        Label eduBackgroundLab = new Label("学历证书");
        eduBackgroundLab.setPrefWidth(labDefaultWidth);//标签默认长度
        eduBackgroundLab.setFont(Font.font(null, FontWeight.BOLD, null, 20));
        //选择学历证书文件按钮
        Button selectEduBackgroundBtn = new Button("选择文件");
        BtnStyle.cancelBtn(selectEduBackgroundBtn);
        selectEduBackgroundBtn.setCursor(Cursor.HAND);
        PageAddStuSelectEduBookBtnAction pageAddStuSelectEduBookBtnAction = new PageAddStuSelectEduBookBtnAction();
        selectEduBackgroundBtn.setOnAction(pageAddStuSelectEduBookBtnAction);
//        //上传按钮
//        Button uploadEduBackgroundBtn = new Button("上传");
//        uploadEduBackgroundBtn.setOnMouseEntered(new EventHandler<MouseEvent>() {
//            @Override
//            public void handle(MouseEvent event) {
//                uploadEduBackgroundBtn.setCursor(Cursor.HAND);
//            }
//        });
//        BtnStyle.cancelBtn(uploadEduBackgroundBtn);
        eduBackgroundHBox.getChildren().addAll(eduBackgroundLab, selectEduBackgroundBtn);


    }

    /**
     * 照片横向盒子
     *
     * @param photoHBox
     */
    private void initPhotoHBox(HBox photoHBox) {
        photoHBox.setPadding(new Insets(20));
        photoHBox.setSpacing(20);
        //照片标签
        Label phoneLab = new Label("照片");
        phoneLab.setPrefWidth(labDefaultWidth);//标签默认长度
        phoneLab.setFont(Font.font(null, FontWeight.BOLD, null, 20));
        //选择照片文件按钮
        Button selectPhoneBtn = new Button("选择文件");
        BtnStyle.cancelBtn(selectPhoneBtn);
        selectPhoneBtn.setCursor(Cursor.HAND);
        PageAddStuSelectPhotoFileBtnAction pageAddStuSelectPhotoFileBtnAction = new PageAddStuSelectPhotoFileBtnAction();
        selectPhoneBtn.setOnAction(pageAddStuSelectPhotoFileBtnAction);
//        //上传按钮
//        Button uploadPhoneBtn = new Button("上传");
//        uploadPhoneBtn.setOnMouseEntered(new EventHandler<MouseEvent>() {
//            @Override
//            public void handle(MouseEvent event) {
//                uploadPhoneBtn.setCursor(Cursor.HAND);
//            }
//        });
//        BtnStyle.cancelBtn(uploadPhoneBtn);
        photoHBox.getChildren().addAll(phoneLab, selectPhoneBtn);

    }

    /**
     * 身份证横向盒子
     *
     * @param idhBox
     */
    private void initIDHBox(HBox idhBox) {
        idhBox.setPadding(new Insets(20));
        idhBox.setSpacing(20);
        //身份证标签
        Label IDLab = new Label("身份证");
        IDLab.setPrefWidth(labDefaultWidth);//标签默认长度
        IDLab.setFont(Font.font(null, FontWeight.BOLD, null, 20));

        //选择文件按钮
        Button selectIDFileBtn = new Button("选择文件");
        BtnStyle.cancelBtn(selectIDFileBtn);

        PageAddApplyStuSelectIDFileBtnAction pageAddApplyStuSelectIDFileBtnAction = new PageAddApplyStuSelectIDFileBtnAction();
        selectIDFileBtn.setOnAction(pageAddApplyStuSelectIDFileBtnAction);
        selectIDFileBtn.setCursor(Cursor.HAND);
//        //上传按钮
//        Button uploadIDBtn = new Button("上传");
//        uploadIDBtn.setOnMouseEntered(new EventHandler<MouseEvent>() {
//            @Override
//            public void handle(MouseEvent event) {
//                uploadIDBtn.setCursor(Cursor.HAND);
//            }
//        });

        ObservableList<Node> children = idhBox.getChildren();
        children.addAll(IDLab, selectIDFileBtn);


    }

    /**
     * 上传文件横向盒子
     *
     * @param fileUploadHBox
     */
    private void initFileUploadHBox(HBox fileUploadHBox) {
        fileUploadHBox.setPadding(new Insets(20));
        //上传文件格式标签
        Label fileUploadLab = new Label("上传文件格式：jpg、jpeg、gif、pdf、png(图片大小限制子在2MB以内)");
        ObservableList<Node> children = fileUploadHBox.getChildren();
        children.addAll(fileUploadLab);
    }

    /**
     * 报名材料横向盒子
     *
     * @param applyMaterialHBox
     */
    private void initApplyMaterialHBox(HBox applyMaterialHBox) {
        applyMaterialHBox.setPadding(new Insets(20));
        //报名材料标签
        Label applyMaterialLab = new Label("报名材料");
        //设置字体大小
        applyMaterialLab.setFont(Font.font(null, FontWeight.BOLD, null, 22));
        applyMaterialLab.setTextFill(Color.rgb(198, 0, 1));//字体颜色
        ObservableList<Node> children = applyMaterialHBox.getChildren();
        children.addAll(applyMaterialLab);
    }

    /**
     * 初始化微信横向盒子
     *
     * @param weChatHBox
     */
    private void initWeChatHBox(HBox weChatHBox) {


        weChatHBox.setSpacing(20);
        weChatHBox.setPadding(new Insets(20));

        //微信标签
        Label weChatLab = new Label("微信*");
        weChatLab.setPrefWidth(labDefaultWidth);//标签默认长度
        weChatLab.setFont(Font.font(null, FontWeight.BOLD, null, 20));

        //微信文本框
        TextField weChatTF = new TextField();
        weChatTF.setId("weChatTF");

        weChatHBox.getChildren().addAll(weChatLab, weChatTF);


    }


    /**
     * 初始化qq横向盒子
     *
     * @param qqHBox
     */
    private void initqqHBox(HBox qqHBox) {

        qqHBox.setSpacing(20);
        qqHBox.setPadding(new Insets(20));
        //qq标签
        Label qqLab = new Label("qq*");
        qqLab.setPrefWidth(labDefaultWidth);//标签默认长度
        qqLab.setFont(Font.font(null, FontWeight.BOLD, null, 20));
        //qq文本框
        TextField qqTF = new TextField();
        qqTF.setId("qqTF");
        qqHBox.getChildren().addAll(qqLab, qqTF);


    }


    /**
     * 移动电话横向盒子
     *
     * @param movePhoneHBox
     */
    private void initMovePhoneHBox(HBox movePhoneHBox) {
        movePhoneHBox.setPadding(new Insets(20));
        movePhoneHBox.setSpacing(20);
        //移动电话标签
        Label movePhoneLab = new Label("移动电话*");
        movePhoneLab.setPrefWidth(labDefaultWidth);//标签默认长度
        movePhoneLab.setFont(Font.font(null, FontWeight.BOLD, null, 20));
        //移动电话文本框
        TextField movePhoneTF = new TextField();
        movePhoneTF.setId("movePhoneTF");
        ObservableList<Node> children = movePhoneHBox.getChildren();
        children.addAll(movePhoneLab, movePhoneTF);


    }

    /**
     * 电子邮箱横向盒子
     *
     * @param emailHBox
     */
    private void initEmailHBox(HBox emailHBox) {
        emailHBox.setPadding(new Insets(20));
        emailHBox.setSpacing(20);
        //电子邮箱标签
        Label emailLab = new Label("电子邮箱*");
        emailLab.setPrefWidth(labDefaultWidth);//标签默认长度
        emailLab.setFont(Font.font(null, FontWeight.BOLD, null, 20));
        //电子邮箱文本框
        TextField emailTF = new TextField();
        emailTF.setId("emailTF");
        ObservableList<Node> children = emailHBox.getChildren();
        children.addAll(emailLab, emailTF);

    }

    /**
     * 所属招生计划横向盒子
     *
     * @param ofEnPHBox
     */
    private void initOfEnPHBox(HBox ofEnPHBox) {
        ofEnPHBox.setPadding(new Insets(20));
        ofEnPHBox.setSpacing(20);
        //所属招生计划标签
        Label ofEnPLab = new Label("所属招生计划*");
        ofEnPLab.setPrefWidth(labDefaultWidth);//标签默认长度
        ofEnPLab.setFont(Font.font(null, FontWeight.BOLD, null, 20));
        //所属招生计划文本框
        TextField ofEnPTF = new TextField();
        ofEnPTF.setId("ofEnPTF");
        //选择招生计划按钮
        Button ofEnPBtn = new Button("选择招生计划");
        BtnStyle.cancelBtn(ofEnPBtn);
        ofEnPBtn.setOnMouseEntered(new EventHandler<MouseEvent>() {
            @Override
            public void handle(MouseEvent event) {
                ofEnPBtn.setCursor(Cursor.HAND);
            }
        });

        ofEnPBtn.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent event) {
                Stage stage = new Stage();
                stage.show();

                stage.setTitle("请选择招生计划");


                //弹出窗界面主盒子
                VBox bigVBox = new VBox();
                bigVBox.setPrefWidth(1000);
                bigVBox.setPrefHeight(700);

                bigVBox.setSpacing(20);
                bigVBox.setPadding(new Insets(10,10,10,30));

                //顶部横向盒子
                HBox topHBox = new HBox();
                topHBox.setSpacing(10);
                topHBox.setPadding(new Insets(20,10,10,20));
                //招生计划编号标签
                Label enpCodeLab = new Label("招生计划编号");
                enpCodeLab.setPrefWidth(labDefaultWidth-100);//标签默认长度
                enpCodeLab.setFont(Font.font(null, FontWeight.BOLD, null, 15));

                //招生计划名称标签
                Label enpNameLab = new Label("招生计划名称");
                enpNameLab.setPrefWidth(labDefaultWidth-100);//标签默认长度
                enpNameLab.setFont(Font.font(null, FontWeight.BOLD, null, 15));


                //招生院校标签
                Label enpSchoolLab = new Label("招生院校");
                enpNameLab.setPrefWidth(labDefaultWidth-100);//标签默认长度
                enpNameLab.setFont(Font.font(null, FontWeight.BOLD, null, 15));

                //招生层次标签
                Label enpLevelLab = new Label("招生层次");
                enpLevelLab.setPrefWidth(labDefaultWidth-100);//标签默认长度
                enpLevelLab.setFont(Font.font(null, FontWeight.BOLD, null, 15));

                //招生专业标签
                Label enpSpecialtyLab = new Label("招生专业");
                enpSpecialtyLab.setPrefWidth(labDefaultWidth-100);//标签默认长度
                enpSpecialtyLab.setFont(Font.font(null, FontWeight.BOLD, null, 15));

                //开始时间标签
                Label startTimeLab = new Label("开始时间");
                startTimeLab.setPrefWidth(labDefaultWidth-100);//标签默认长度
                startTimeLab.setFont(Font.font(null, FontWeight.BOLD, null, 15));

                //截止时间标签
                Label endTimeLab = new Label("截止时间");
                endTimeLab.setPrefWidth(labDefaultWidth-100);//标签默认长度
                endTimeLab.setFont(Font.font(null, FontWeight.BOLD, null, 15));

                //计划招生人数标签
                Label enpPeoples = new Label("计划招生人数");
                enpPeoples.setPrefWidth(labDefaultWidth-100);//标签默认长度
                enpPeoples.setFont(Font.font(null, FontWeight.BOLD, null, 15));


                //报名人数
                Label regPeoples = new Label();
                regPeoples.setPrefWidth(labDefaultWidth-100);//标签默认长度
                regPeoples.setFont(Font.font(null, FontWeight.BOLD, null, 15));


                //第一个招生计划横向盒子
                HBox enpHBox1 = new HBox();

                //多选框
                CheckBox enp1CB = new CheckBox();











                //滚动条盒子
                VBox scrollPaneVBox = new VBox();
                ScrollPane scrollPane = new ScrollPane();
                scrollPane.setContent(scrollPaneVBox);
                scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.ALWAYS);
                scrollPane.setPrefSize(1000, 700);


                //顶部横向盒子把东西带走
                topHBox.getChildren().addAll(enpCodeLab,enpNameLab,enpSchoolLab,enpLevelLab,enpSpecialtyLab,startTimeLab,endTimeLab,enpPeoples,regPeoples);

                //第一个招生计划盒子
                enpHBox1.getChildren().addAll(enp1CB);
                scrollPaneVBox.getChildren().addAll(topHBox,enpHBox1);

                //主盒子把滚动条带走
                bigVBox.getChildren().addAll(scrollPane);


                Scene scene = new Scene(bigVBox);
                stage.setScene(scene);






            }
        });
        ObservableList<Node> children = ofEnPHBox.getChildren();
        children.addAll(ofEnPLab, ofEnPTF, ofEnPBtn);
    }


    /**
     * 证件号码横向盒子
     *
     * @param idNumHBox
     */
    private void initIDNumHBox(HBox idNumHBox) {
        idNumHBox.setPadding(new Insets(20));
        idNumHBox.setSpacing(20);
        //证件号码标签
        Label IDNumLab = new Label("证件号码*");
        IDNumLab.setPrefWidth(labDefaultWidth);//标签默认长度
        IDNumLab.setFont(Font.font(null, FontWeight.BOLD, null, 20));
        //证件号码文本框
        TextField IDNumTF = new TextField();
        IDNumTF.setId("IDNumTF");
        ObservableList<Node> children = idNumHBox.getChildren();
        children.addAll(IDNumLab, IDNumTF);

    }

    /**
     * 证件类型横向盒子
     *
     * @param idTypeHBox
     */
    private void initIDTypeHBox(HBox idTypeHBox) {
        idTypeHBox.setPadding(new Insets(20));
        idTypeHBox.setSpacing(20);
        //证件类型标签
        Label IDTypeLab = new Label("证件类型*");
        IDTypeLab.setPrefWidth(labDefaultWidth);//标签默认长度
        IDTypeLab.setFont(Font.font(null, FontWeight.BOLD, null, 20));
        //证件类型下拉框
        ComboBox IDTpeCB = new ComboBox<>();
        IDTpeCB.getItems().add("身份证");
        IDTpeCB.getItems().add("军官证");
        IDTpeCB.setId("IDTpeCB");
        IDTpeCB.getSelectionModel().selectFirst();
        ObservableList<Node> children = idTypeHBox.getChildren();
        children.addAll(IDTypeLab, IDTpeCB);


    }

    /**
     * 出生日期横向盒子
     *
     * @param birthdayHBox
     */
    private void initBirthdayHBox(HBox birthdayHBox) {
        birthdayHBox.setPadding(new Insets(20));
        birthdayHBox.setSpacing(20);
        //出生日期标签
        Label birthdayLab = new Label("出生日期*");
        birthdayLab.setPrefWidth(labDefaultWidth);//标签默认长度
        birthdayLab.setFont(Font.font(null, FontWeight.BOLD, null, 20));
        //日期选择器
        DatePicker birthdayDP = new DatePicker();
        birthdayDP.setId("birthdayDP");
        ObservableList<Node> children = birthdayHBox.getChildren();
        children.addAll(birthdayLab, birthdayDP);


    }

    /**
     * 性别横向盒子
     *
     * @param genderHBox
     */
    private void initGenderHBox(HBox genderHBox) {
        genderHBox.setPadding(new Insets(20));
        genderHBox.setSpacing(20);
        //性别标签
        Label genderLab = new Label("性别*");
        genderLab.setPrefWidth(labDefaultWidth);//标签默认长度
        genderLab.setFont(Font.font(null, FontWeight.BOLD, null, 20));
        //性别下拉框
        ComboBox genderCB = new ComboBox<>();
        genderCB.getItems().add("男");
        genderCB.getItems().add("女");
        genderCB.setId("genderCB");

        genderCB.getSelectionModel().selectFirst();
        ObservableList<Node> children = genderHBox.getChildren();
        children.addAll(genderLab, genderCB);


    }

    /**
     * 姓名横向盒子
     *
     * @param nameHBox
     */
    private void initNameHBox(HBox nameHBox) {
        nameHBox.setPadding(new Insets(20));
        nameHBox.setSpacing(20);
        //姓名标签
        Label nameLab = new Label("姓名*");
        nameLab.setPrefWidth(labDefaultWidth);
        nameLab.setFont(Font.font(null, FontWeight.BOLD, null, 20));
        //姓名文本框
        TextField nameTF = new TextField();
        nameTF.setId("nameTF");
        ObservableList<Node> children = nameHBox.getChildren();
        children.addAll(nameLab, nameTF);

    }

    /**
     * 报名编号横向盒子
     *
     * @param applyNumHBox
     */
    private void initApplyNumHBox(HBox applyNumHBox) {
        applyNumHBox.setPadding(new Insets(20));
        applyNumHBox.setSpacing(20);
        //报名编号标签
        Label applyNumLab = new Label("报名编号");

        applyNumLab.setPrefWidth(labDefaultWidth);
        applyNumLab.setFont(Font.font(null, FontWeight.BOLD, null, 20));
        //报名编号文本框
        TextField applyNumTF = new TextField();
        applyNumTF.setId("applyNumTF");
        ObservableList<Node> children = applyNumHBox.getChildren();
        children.addAll(applyNumLab, applyNumTF);

    }

    /**
     * 新增报名信息横向盒子
     *
     * @param addApplyInfoHBox
     */
    private void initAddApplyInfoHBox(HBox addApplyInfoHBox) {
        addApplyInfoHBox.setPadding(new Insets(20));
        //新增报名信息标签
        Label addApplyInfoLab = new Label("新增报名信息");
        //设置字体大小
        addApplyInfoLab.setFont(Font.font(null, FontWeight.BOLD, null, 22));
        addApplyInfoLab.setTextFill(Color.rgb(198, 0, 1));//字体颜色

        ObservableList<Node> children = addApplyInfoHBox.getChildren();
        children.addAll(addApplyInfoLab);
    }

    /**
     * 顶部横向盒子
     *
     * @param topHBox
     */
    private void initTopHBox(HBox topHBox) {

        topHBox.setSpacing(20);
        topHBox.setPadding(new Insets(20));
        //顶部标签
        Label topLab = new Label("当前位置：🏠>招生管理>报名学员管理>新增报名信息");
        topLab.setFont(new Font(20));//设置字体大小
        ObservableList<Node> children = topHBox.getChildren();
        children.addAll(topLab);

    }


}
